//
//  RootVieViewController.m
//  UI _ 嵌套
//
//  Created by bmli on 16/6/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "RootVieViewController.h"
#import "TableViewController.h"

@interface RootVieViewController ()<UICollectionViewDelegate , UICollectionViewDataSource>

@property (nonatomic , retain)UICollectionView * collection;

@property (nonatomic , retain)TableViewController * Table;

@end

@implementation RootVieViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatFong];
}
- (void)creatFong{
    UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
    layout.minimumLineSpacing =0;
    layout.scrollDirection  = UICollectionViewScrollDirectionHorizontal;
    
    layout.itemSize = CGSizeMake(CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds));
    
    self.collection = [[UICollectionView alloc]initWithFrame:self.view.frame collectionViewLayout:layout];
    self.collection.pagingEnabled = YES;
    self.collection.delegate = self;
    self.collection.dataSource = self;
/**注册*/
    [self.collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"BMLI1"];
    
    [self.view addSubview:self.collection];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BMLI1" forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor whiteColor];
    
    self.Table = [[TableViewController alloc] init];
    
    // 一定要给大小
    self.Table.view.frame = cell.contentView.bounds;
    
    [cell.contentView addSubview:self.Table.view];
    [self addChildViewController:self.Table];
    
    return cell;
    
}



@end
